package com.study.easyexcel.read;

import java.util.Arrays;
import java.util.List;

/**
 * <b><code>Test1</code></b>
 * <p>
 * TODO
 * <p/>
 *
 * @author xiangdan xiangdan@dtxytech.com
 * time 2023/11/16 星期四 13:46
 */
public class Test1 {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(3,2,4,5,61,1,99);
        Integer i = list.stream().max((a, b) -> {
            return a.compareTo(b);
        }).get();
        Integer i2 = list.stream().min((a, b) -> {
            return a.compareTo(b);
        }).get();
        System.out.println(i);
        System.out.println(i2);

        List<A> list1 = Arrays.asList(
                new A(12,"张三1"),
                new A(6,"张三2"),
                new A(33,"张三3"),
                new A(22,"张三4"),
                new A(44,"张三5"),
                new A(99,"张三6"),
                new A(66,"张三7"));


        A a = list1.stream().max((c1, c2) -> {
            return c1.age.compareTo(c2.age);
        }).get();
        System.out.println(a);

        A a2 = list1.stream().min((c1, c2) -> {
            return c1.age.compareTo(c2.age);
        }).get();
        System.out.println(a2);
    }


    public static class A{
        public Integer age;
        public String name;

        public A(Integer age, String name) {
            this.age = age;
            this.name = name;
        }

        @Override
        public String toString() {
            return "A{" +
                    "age=" + age +
                    ", name='" + name + '\'' +
                    '}';
        }
    }
}
